#ifndef _HELIX_ODE_PHYSICS_OBJECT_H_
#define _HELIX_ODE_PHYSICS_OBJECT_H_

#include "../../Helix.h"
#include "../../HObject.h"
#include "../../Log.h"
#include "../../Math/HelixMath.h"
#include <ode/ode.h>
#include "Physics.h"
#include "ODEPhysics.h"
#include "PhysObjRepresentation.h"
#include "PhysObject.h"


namespace helix
{

	/** \see PhysObject
	*/
	class MY_CLASS ODEPhysObject : public PhysObject 
	{
	private:
		dBodyID body;
		dGeomID geometry;
		ODEPhysics *physics;
		float mass;

		bool staticGeom;

		void initPhysicsRep(PhysRepresentation *representation);
		void initPhysicsRepSphere(SphereRepresentation *representation);
		void initPhysicsRepBox(BoxRepresentation *representation);
		void initPhysicsRepPlane(PlaneRepresentation *representation);
	public:
		ODEPhysObject(ODEPhysics *physics,PhysRepresentation *representation,bool isStatic);

		/** Default destructor
		*/
		virtual ~ODEPhysObject();

		/**	Change the world position of this physics object to the one specified in the Vector.
		*	\warning Changing an object's position via this method does not guarantee that 
		*	the object will collide with anything that is between its current and new positions
		*	\param pos A vector that contains the new world position of the object
		*/
		virtual void setPosition(Vector pos);

		/**	Change the mass of this object
		*	\note Some physics engines will let you give an object an infinite mass.  Generally this 
		*	is reserved for things like cutscenes, or platforms, or anything that should not be affected
		*	by collisions of other objects.  Use a negative value to specify that this object should have
		*	an infinite mass.
		*	\param pos A vector that contains the new world position of the object
		*/
		virtual void setMass(float mass);

		/**	Change the velocity of this physics object to the one specified in the Vector.
		*	\param vel A vector that contains the new velocity of the object
		*/
		virtual void setVelocity(Vector vel);

		/**	Get the object's current position
		*	\return a Vector containing the world position of the object
		*/
		virtual Vector getPosition();

		/**	Get the object's current velocity
		*	\return a Vector containing the object's velocity
		*/
		virtual Vector getVelocity();

		
		/**	Get the object's mass
		*	\return the object's mass.  If the mass is infinite, a negative value will be returned.
		*/
		virtual float getMass();

		virtual bool isStatic();

		/** Get the current position and orientation of the object in world space
		*	\return A Matrix4x4 object that contains the position and orientation of the object
		*/
		virtual Matrix4x4 getTransformationMatrix();
	};

}

#endif